import math

class Solution(object):
    def evalRPN(self, tokens):
        """
        :type tokens: List[str]
        :rtype: int
        """
        stack = []
        for tok in tokens:
            print(stack)
            if tok not in ['+', '-', '*', '/']:
                stack.append(int(tok))
            else:
                factor1 = stack[-1]
                factor0 = stack[-2]
                if tok=='+':
                    stack[-2]=factor0+factor1
                elif tok=='-':
                    stack[-2]=factor0-factor1
                elif tok=='*':
                    stack[-2]=factor0*factor1
                else:
                    val = float(factor0)/float(factor1)
                    if val<0: val = -math.floor(abs(val))
                    else: val = math.floor(val)
                    stack[-2]=int(val)
                stack.pop()
        return stack[-1]

print(Solution().evalRPN(["10","6","9","3","+","-11","*","/","*","17","+","5","+"]))
